import React from "react";
import Link from "umi/link";
import withRouter from 'umi/withRouter';
import { connect } from 'dva';
import Transaction from './components/Transaction'
import Receipt from './components/Receipt'

import style from './index.less';


class TransactionDetail extends React.Component {
  componentDidMount() {
    document.documentElement.scrollTo(0, 0);
  }

  render() {
    return (
      <div className={style.container}>
        <div className={style.nav}>
          <Link to="/">首页</Link> / 交易-{this.props.match.params.id}
        </div>
        {
          <div className={style.transactionInfo}>
            <Transaction data={this.props.data}/>
          </div>
        }
        {
          this.props.data.data ?
            (
              <div className={style.receiptInfo}>
                <Receipt data={this.props.data.data}/>
              </div>
            ) : null
        }
      </div>
    )
  }
}

function mapStateToProps(state) {
  const { data } = state.transaction;
  return {
    data,
  };
}

export default connect(mapStateToProps)(withRouter(TransactionDetail));
